import * as constants from './constants'
import { post } from '../../../request'

export const setOrderStatusMap = value => ({
  type: constants.SET_ORDER_STATUS,
  value
})

export const setCurrentPage = value => ({
  type: constants.SET_CURRENT_PAGE,
  value
})

export const getOrderStatusMap = () => {
  return dispatch => {
    post('/v1/bk/market/orderstatus/gets').then(res => {
      if (!res.code) {
        const statusMap = {}
        res.data.forEach(item => (statusMap[item.status] = item.name))
        dispatch(setOrderStatusMap(statusMap))
      }
    })
  }
}
